<?php
/**
 * 地图导航
 *
 * @copyright  Copyright (c) 2015-2025 NcPHP Inc. (http://www.ncphp.com)
 * @license    http://www.ncphp.com/
 * @link       http://www.ncphp.com/
 * @author     NcPHP Team
 * @since      File available since Release v1.1
 */
defined('InNcPHP') or exit('Access Invalid!');

class mapControl extends BaseHomeControl{

    public function __construct(){
        parent::__construct();
    }

    public function indexOp(){
        Tpl::showpage('map.index');
    }

    /**
     * 获取门票
     */
    public function ticket_mapOp()
    {
        /* @var ticketModel $ticket_model  */
        $ticket_model = Model('ticket');
        $where = array();
        $where['tk_status'] =1;
        $where['audio'] = array('neq','');
        $tk_list = $ticket_model->getTicketList($where,'tk_id,tk_title,tk_thumb,tk_addr,tk_lat,tk_lng,audio,tk_subtitle');
        $result = array();
        if($tk_list && is_array($tk_list))
        {
            foreach($tk_list as $key =>$value){
                if($value['tk_lng']){
                    $result[$key] = $value;
                    $result[$key]['icon'] =AST_URL. 'images/video_addr.png';
                    $jd = array();
                    $jd[] = $value['tk_lng'];
                    $jd[] = $value['tk_lat'];
                    $result[$key]['position'] = $jd;
                    $result[$key]['tk_thumb'] = UPLOAD . 'product/' .$value['tk_thumb'];
                    $result[$key]['audio'] = UPLOAD.'video/'.$value['audio'];
                    $result[$key]['url'] =  HOST_URL.'/wxweb/index.php?act=ticket&op=ticket_info&tk_id='.$value['tk_id'];
                }
            }
        }
        //echo json_encode($result);exit;
        Tpl::output('movecar',json_encode($result));
        Tpl::showpage('ticket.map','null_layout');
    }

    public function test_mapOp()
    {

        Tpl::showpage('test.map','new_layout');
    }

    /**
     * 显示自己的位置
     */
    public function map_infoOp()
    {
        Tpl::showpage('map.info','null_layout');
    }

    /**
     * 地图定位页面 获取所有的移动车的数据
     */
    public function mapOp(){
        Tpl::output('_title','移动酒仓-移动车');
        $setting_list  = Model('setting')->getListSetting();

        Tpl::output('footer','map');
//        if(!$setting_list['move_car_status']){
//            Tpl::output('mover_car_closed_reason',$setting_list['mover_car_closed_reason']);
//            Tpl::showpage('no_open');
//        }

        //获取移动车 位置
        $movecar_model = Model('movecar');
        $movecar_list = $movecar_model->getMovecarList(array('mc_state'=>1,'is_delete'=>0,'mc_lat>0'));
        $result = array();
        foreach($movecar_list as $key=>$value){
            if(!empty($value['mc_lng'])){
                if($value['mc_type']==1){
                    $result[$key]['icon']=AST_URL.'images/map_icon1.png';
                }else{
                    $result[$key]['icon']=AST_URL.'images/map_icon4.png';
                }
                $jd=array();
                $jd[]=$value['mc_lng'];
                $jd[]=$value['mc_lat'];
                $result[$key]['position']=$jd;
                $result[$key]['car_no']=$value['mc_name'];
                $result[$key]['car_id']=$value['mc_id'];
            }
        }
        Tpl::output('movecar',json_encode($result));

        Tpl::showpage('map');
    }
}
